<?php
ob_start();
require_once '../sub/init.php';
if(is_mobile())header("Location: ".mHref('my_hongniang'));
$currfields = "grade,admid,crm_qxnum,crm_yjnum";
require_once 'my_chkuser.php';
require_once ZEAI.'cache/udata.php';
require_once ZEAI.'cache/config_vip.php';
require_once ZEAI.'cache/config_crm.php';
$zeai_cn_menu = 'my_hongniang';
if($t!='hn' && $t!='qx' && $t!='yj')$t='hn';$f=intval($f);
$cook_grade = intval($row['grade']);
$cook_admid = intval($row['admid']);
$cook_crm_qxnum = intval($row['crm_qxnum']);
$cook_crm_yjnum = intval($row['crm_yjnum']);
switch ($t) {
	case 'hn':
		$t_str='我的红娘';
	break;
	case 'qx':
		$t_str='牵线记录';
		if(!empty($f))$SQL=" AND a.flag=$f";
		$qxnum1 = $db->COUNT(__TBL_QIANXIAN__,"flag=2 AND (uid=".$cook_uid." OR senduid=".$cook_uid.")");
		$qxnum2 = $db->COUNT(__TBL_QIANXIAN__,"flag=1 AND (uid=".$cook_uid." OR senduid=".$cook_uid.")");
		$qxnum3 = $db->COUNT(__TBL_QIANXIAN__,"flag=-1 AND (uid=".$cook_uid." OR senduid=".$cook_uid.")");
		$ZEAI_SQL = "a.senduid=b.id AND (a.senduid=".$cook_uid." OR a.uid=".$cook_uid." )".$SQL;
		$ZEAI_SELECT="SELECT a.senduid,a.uid,a.admid,a.admname,a.addtime,a.flag,b.sex,b.grade,b.nickname,b.photo_s,b.photo_f,b.photo_ifshow,b.flag AS uflag FROM ".__TBL_QIANXIAN__." a,".__TBL_USER__." b WHERE ".$ZEAI_SQL." ORDER BY a.id DESC";
	break;
	case 'yj':
		$t_str='约见记录';
		if(ifint($f))$SQL=" AND a.meet_flag=$f";
		$yjnum1 = $db->COUNT(__TBL_CRM_MATCH__,"meet_flag=3 AND (uid=".$cook_uid." OR uid2=".$cook_uid.")");//完成
		$yjnum2 = $db->COUNT(__TBL_CRM_MATCH__,"meet_flag=1 AND (uid=".$cook_uid." OR uid2=".$cook_uid.")");//进行中
		$yjnum3 = $db->COUNT(__TBL_CRM_MATCH__,"meet_flag=2 AND (uid=".$cook_uid." OR uid2=".$cook_uid.")");//暂停
		$ZEAI_SQL = "a.uid2=b.id AND (a.uid2=".$cook_uid." OR a.uid=".$cook_uid." )".$SQL;
		$ZEAI_SELECT="SELECT a.uid2 AS senduid,a.uid,a.admid,a.admname,a.addtime,a.meet_flag AS flag,b.sex,b.grade,b.nickname,b.photo_s,b.photo_f,b.photo_ifshow,b.flag AS uflag FROM ".__TBL_CRM_MATCH__." a,".__TBL_USER__." b WHERE ".$ZEAI_SQL." ORDER BY a.id DESC";
		
	break;
}

?>
<!doctype html><html><head><meta charset="utf-8">
<title>我的红娘 - <?php echo $_ZEAI['siteName'];?></title>
<link href="<?php echo RES;?>p/css/p.css?<?php echo $_ZEAI['cache_str'];?>" rel="stylesheet" type="text/css" />
<link href="<?php echo RES;?>p/css/my.css?<?php echo $_ZEAI['cache_str'];?>" rel="stylesheet" type="text/css" />
<link href="<?php echo RES;?>p/css/my_hongniang.css?<?php echo $_ZEAI['cache_str'];?>" rel="stylesheet" type="text/css" />
<link href="<?php echo HOST;?>/cache/zeaicolor.css?<?php echo $_ZEAI['cache_str'];?>" rel="stylesheet" type="text/css" />
<script src="<?php echo RES;?>www_zeai_cn.js?<?php echo $_ZEAI['cache_str'];?>"></script>
<script src="<?php echo RES;?>p/js/p.js?<?php echo $_ZEAI['cache_str'];?>"></script>
<style>
.hninfo p b{background-color:rgba(<?php echo c16_rgb($_ZEAI['mob_mbcolor']);?>,.8)}
</style>
</head>
<body>
<?php require_once ZEAI.'p/my_top.php'; ?>
<div class="main"><div class="mainL"><?php require_once ZEAI.'p/my_left.php';?></div><div class="mainR">
    <div class="myRM">
        <h1>我的红娘</h1>
        <div class="tab">
            <a href="my_hongniang.php?t=hn&jumpurl=<?php echo $jumpurl;?>"<?php echo ($t == 'hn')?' class="ed"':'';?>>我的红娘</a>
            <a href="my_hongniang.php?t=qx&jumpurl=<?php echo $jumpurl;?>"<?php echo ($t == 'qx')?' class="ed"':'';?>>牵线记录</a>
            <a href="my_hongniang.php?t=yj&jumpurl=<?php echo $jumpurl;?>"<?php echo ($t == 'yj')?' class="ed"':'';?>>约见记录</a>
        </div>
         <!-- start C -->
        <div class="myRC">
			<?php if ($t == 'hn'){?>
			<div class="my_hongniang">
            	<?php if (!ifint($cook_admid)){?>
                        <?php echo '<br><br>'.nodatatips('您暂时还没有牵手红娘线下服务<br>请升级VIP会员享受红娘线下1对1牵线<br><br><a href="my_vip.php" class="nohnbtn btn size3 HONG">升级VIP会员</a><br><br><a href="'.Href('hongniang').'" class="nohnbtn btn size3 HONG2">进入红娘大厅</a>');?>
            	<?php }else{
					$row = $db->ROW(__TBL_CRM_HN__,"sex,qq,weixin,mob,path_s,ewm,truename,sex,title,click","flag=1 AND id=".$cook_admid,"name");
					if ($row){
						$truename = trimhtml(dataIO($row['truename'],'out',7));
						$title    = trimhtml(dataIO($row['title'],'out'));
						$click    = $row['click'];
						$sex      = $row['sex'];
						$path_s   = $row['path_s'];
						$ewm      = $row['ewm'];
						$qq = dataIO($row['qq'],'out');
						$weixin = dataIO($row['weixin'],'out');
						$mob = dataIO($row['mob'],'out');
						//
						$path_s_url = (!empty($path_s))?UP.smb($path_s,'b'):RES.'photo_m'.$sex.'.png';
						$sexbg   = (empty($path_s))?' class="sexbg'.$sex.'"':'';
						$ewm_str    = (!empty($ewm))?'<img src="'.UP.$ewm.'"'.$sexbg.'>':'暂无';
					}else{nodatatips('红娘已离职');}
					?>
                    <div class="hninfo">
                        <p style="background-image:url(<?php echo $path_s_url; ?>)"<?php echo $sexbg; ?>><b>工号：<?php echo $cook_admid;?></b></p>
                        <em>
                            <div class="title">
                                <h2><?php echo $truename;?><span><i class="ico">&#xe643;</i><font><?php echo $click;?></font></span></h2>
                                <div class="titlestr"><?php echo $title;?></div>
                                <a href="<?php echo Href('hongniang',$cook_admid);?>" target="_blank" class="btn size4 hnhome HONG2">红娘主页</a>
                            </div>
                        </em>
                    </div>
                    <div class="detaicotact">
                    	<div class="linebox"><div class="line "></div><div class="title BAI">联系红娘</div></div><br><br>
                        <?php if (!empty($mob)){ ?><li><p class="ico telico">&#xe7c1;</p>红娘热线：<span><?php echo $mob; ?></span></li><?php }?>
                        <?php if (!empty($qq)){ ?><li><p class="ico qqico">&#xe623;</p>红娘QQ：<span><?php echo $qq; ?></span><?php if(!empty($qq)){?><a href="tencent://message/?uin=<?php echo $qq; ?>&Site=<?php echo $truename; ?>&Menu=yes"><img src="<?php echo RES;?>qq2.gif" alt="红娘QQ服务" class="middle" style="margin-top:-3px" /></a><?php }?></li><?php }?>
                        <?php if (!empty($weixin)){ ?><li><p class="ico wxico">&#xe607;</p>红娘微信：<span><?php echo $weixin; ?></span></li><?php }?>
                        <?php if (!empty($ewm)){ ?>
                        <div class="hnewm"><?php echo $ewm_str; ?><h6>微信扫码加红娘微信</h6></div>
                        <?php }?>
                    </div>
                <?php }?>
            </div>
            <?php }elseif($t=='qx' || $t=='yj'){ ?>
            <div class="my_qxyj_info">
                <?php if ($t == 'qx'){?>
                    <a href="my_hongniang.php?t=qx&f=2&jumpurl=<?php echo $jumpurl;?>"><i class="ico success"><em><b><?php echo $qxnum1;?></b>次</em></i><span<?php echo ($f == 2)?' class="zeaicolor"':'';?>>成功了</span></a>
                    <a href="my_hongniang.php?t=qx&f=1&jumpurl=<?php echo $jumpurl;?>"><i class="ico doing"><em><b><?php echo $qxnum2;?></b>次</em></i><span<?php echo ($f == 1)?' class="zeaicolor"':'';?>>进行中</span></a>
                    <a href="my_hongniang.php?t=qx&f=-1&jumpurl=<?php echo $jumpurl;?>"><i class="ico fail"><em><b><?php echo $qxnum3;?></b>次</em></i><span<?php echo ($f == -1)?' class="zeaicolor"':'';?>>失败了</span></a>
                <?php }else{ ?>
                    <a href="my_hongniang.php?t=yj&f=3&jumpurl=<?php echo $jumpurl;?>"><i class="ico success"><em><b><?php echo $yjnum1;?></b>次</em></i><span<?php echo ($f == 3)?' class="zeaicolor"':'';?>>已完成</span></a>
                    <a href="my_hongniang.php?t=yj&f=1&jumpurl=<?php echo $jumpurl;?>"><i class="ico doing"><em><b><?php echo $yjnum2;?></b>次</em></i><span<?php echo ($f == 1)?' class="zeaicolor"':'';?>>进行中</span></a>
                    <a href="my_hongniang.php?t=yj&f=2&jumpurl=<?php echo $jumpurl;?>"><i class="ico fail"><em><b><?php echo $yjnum3;?></b>次</em></i><span<?php echo ($f == 2)?' class="zeaicolor"':'';?>>暂停中</span></a>
                <?php }?>
            </div>
            <div class="my_hn_qx">
				<?php 
                $rt=$db->query($ZEAI_SELECT);
                $total = $db->num_rows($rt);
                if($total>0){
                    $page_skin=2;$pagemode=4;$pagesize=8;$page_color=$_ZEAI['mob_mbcolor'];require_once ZEAI.'sub/page.php';
                    for($i=0;$i<$pagesize;$i++) {
                        $rows = $db->fetch_array($rt,'name');
                        if(!$rows)break;
						echo rows_ulist($rows,$p);
					}
                    if ($total > $pagesize)echo '<div class="pagebox mypagebox">'.$pagelist.'</div>';
                }else{echo nodatatips('暂无牵线约见记录～～');}?>
            </div>
        <?php }?>
        </div>
        <!-- end C -->
</div></div></div>
<?php
function rows_ulist($rows,$p) {
	global $_ZEAI,$t,$db,$_CRM;
	$meet_flagARR = json_decode($_CRM['meet_flag'],true);
	$qxflagARR    = json_decode($_CRM['qxflag'],true);
	$uid   = $rows['uid'];
	$admid = $rows['admid'];
	$admname = dataIO($rows['admname'],'out');
	$addtime = YmdHis($rows['addtime'],'Ymd');
	$flag = $rows['flag'];
	$flagT = ($t=='yj')?crm_arr_title($meet_flagARR,$flag):crm_arr_title($qxflagARR,$flag);
	//senduid
	$senduid = $rows['senduid'];
	$sendnickname = trimhtml(dataIO($rows['nickname'],'out'));
	$sex     = $rows['sex'];
	$grade   = $rows['grade'];
	$photo_s = $rows['photo_s'];
	$photo_f = $rows['photo_f'];
	$photo_ifshow = $rows['photo_ifshow'];
	$uflag = $rows['uflag'];
	$photo_s_url = photo_s_out('{"smb":"s","sex":"'.$sex.'","photo_s":"'.$photo_s.'","photo_f":"'.$photo_f.'","photo_ifshow":"'.$photo_ifshow.'","uflag":"'.$uflag.'","outkind":"url"}');	
	//uid
	$row2 = $db->ROW(__TBL_USER__,"sex,grade,nickname,photo_s,photo_f,photo_ifshow,flag AS uflag","id=".$uid,"name");
	if ($row2){
		$sex2      = $row2['sex'];
		$grade2    = $row2['grade'];
		$photo_s2  = $row2['photo_s'];
		$photo_f2  = $row2['photo_f'];
		$photo_ifshow2 = $row2['photo_ifshow'];
		$uflag2    = $row2['uflag'];
		$nickname2 = dataIO($row2['nickname'],'out');
		$photo_s_url2 = photo_s_out('{"smb":"s","sex":"'.$sex2.'","photo_s":"'.$photo_s2.'","photo_f":"'.$photo_f2.'","photo_ifshow":"'.$photo_ifshow2.'","uflag":"'.$uflag2.'","outkind":"url"}');	
	}
	$O  = '<ul>';
	$O .= '	<li><a href="'.a('{"kind":"u","uid":"'.$senduid.'"}').'" target="blank"><img src="'.$photo_s_url.'" class="s"><em>'.uicon($sex.$grade).'<font>'.$senduid.'</font></br>'.$sendnickname.'</em></a></li>';
	$O .= '	<li><h5>'.$addtime.'</h5><i class="ico">&#xe62d;</i><span>'.$flagT.'</span></li>';
	$O .= '	<li><a href="'.a('{"kind":"u","uid":"'.$uid.'"}').'" target="blank"><img src="'.$photo_s_url2.'" class="s"><em>'.uicon($sex2.$grade2).'<font>'.$uid.'</font></br>'.$nickname2.'</em></a></li>';
	$O .= '<div class="clear"></div></ul>';
	return $O;
}
require_once ZEAI.'p/bottom.php';ob_end_flush();?>